from nodetypes.formats.mml.Events import EventHandler

from forms import Reset


class EventHandler(EventHandler):  
            
    newResetForm       = Reset.Form
    
    def process(self, context, source):
        eventData = context.event.data
        session = context.session
        
        if session.isPersistent():
            session.logout()
            eventData.status = u'success'
            eventData.status_type = u'logoff-success'
        else:
            eventData.status = u'failure'
            eventData.status_type = u'logoff-failure'
            
        eventData.form = self.newResetForm()
        eventData.stage = 0
        eventData.submits = context.transform.submitEvents[0]
        
        context.model = context.nodeType.retrieveModel(context)
        
        return self.newDocument().createDocument(context, source)